/*
 * @Author: sdq 483657864@qq.com
 * @Date: 2025-04-18 11:47:04
 * @LastEditors: sdq 483657864@qq.com
 * @LastEditTime: 2025-04-18 17:17:14
 * @FilePath: \ranyu_anchor_new\src\agroa\listenter\netWorkQuality.ts
 * @Description: 网络质量报告（每秒触发）
 */
import { NetworkQuality } from "agora-rtc-sdk-ng";
export const agoraNetWorkIndicatorListenter = async () => {
  // 动态导入，减少不必要的加载
  const { agoraClient } = await import("../initAgoraSdk");
  const { useLiveStatusStore } = await import("@/store");
  const liveStatusStore = useLiveStatusStore();
  /**
   * @description mountNetWorkIndicatorListenter - 网络质量报告（每秒触发）
   */
  const mountNetWorkIndicatorListenter = () => {
    agoraClient.value?.on("network-quality", (quality: NetworkQuality) => {
      const newQuality = quality.uplinkNetworkQuality;
      upadtaNetworkQuality(newQuality);
    });
  };
  /**
   *
   * @param quality -
   */
  const upadtaNetworkQuality = (quality: number) => {
    liveStatusStore.changenetworkQuality(quality);
  };
  return {
    mountNetWorkIndicatorListenter,
  };
};
